package livingarea.Members;

import livingarea.actions.DethType;
import livingarea.actions.EatingType;
import livingarea.LivingArea;
import livingarea.actions.MoveType;
import livingarea.actions.SpawnType;

/**
 * Class that describe beast object.
 *
 * @author Muzalevskiy Vitaliy
 */
public abstract class Beast implements AreaMember {
    
    /**Object of <code> LivingArea </code> type in which current beast lives.*/
    private LivingArea livingArea;
    private Position position;
    private int lifeCount;
    /**Number of eaten fishes.*/
    private int eatCount;
    /**Current object realized movement behavior of current beast.*/
    protected MoveType moveType;
    /**Current object realized eating behavior of current beast.*/
    protected EatingType eatingType;
    /**Current object realized spawn behavior of current beast.*/
    protected SpawnType spawnType;
    /**Current object realized death behavior of current beast.*/
    protected DethType dethType;
    
    /**
     * Constructor of current class that create beast in entered living area
     * with random position.
     *
     * @param livingArea - living area in which current beast will be created.
     */
    public Beast(LivingArea livingArea){
        this.livingArea = livingArea;
        position = livingArea.getCoordinates().setMemberPosition();
        livingArea.addMember(this);
    }
    
    /**
     * Constructor of current class that create beast in entered living area
     * with position values indicated as parameters.
     *
     * @param livingArea - living area in which current beast will be created.
     * @param position - position value of a beast in living area.
     */
    public Beast(LivingArea livingArea, Position position){
        this.livingArea = livingArea;
        this.position = position;
        livingArea.addMember(this);
    }

    @Override
    public Position getPosition() {
        return position;
    }
    
    public void changePosition(int x, int y){
        position = new Position(x, y);
    }

    @Override
    public int getLifeCount() {
        return lifeCount;
    }

    @Override
    public LivingArea getLivingArea() {
        return livingArea;
    }

    @Override
    public void increaseLifeCount() {
        lifeCount++;
    }

    public int getEatCount() {
        return eatCount;
    }

    public void increaseEatCount() {
        eatCount++;
    }
    
    public void resetEatCount() {
        eatCount = 0;
    }

    public abstract boolean isPray();
    
    @Override
    public boolean isMovable(){
        return true;
    }
}
